package com.tt.plat8.bootstrap;


import com.tt.plat8.bootstrap.utils.JNDIHelper;
import com.tt.plat8.userbase.service.UserService;


import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.service.http.HttpService;

/**
 * Created with IntelliJ IDEA.
 * UserBean: tangtao
 * Date: 14-1-10
 * Time: 下午12:10
 * To change this template use File | Settings | File Templates.
 */
public class CoreServlet extends HttpServlet implements BundleActivator {


   private static   BundleContext bundleContext;

   private Log log = LogFactory.getLog(CoreServlet.class);
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);    //To change body of overridden methods use File | Settings | File Templates.
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("-------------ddd");

        log.info("--------------------测试日志打印-----------------");

        log.debug("--------------------debug测试日志打印-----------------");

      Object xaDataSource = JNDIHelper.getJNDIService("jdbc/mysql");
//       Object kkk =  JNDIHelper.getJNDIService(EntityManagerFactory.class.getName()+"/(osgi.unit.name=testM)");
//
//        System.out.println("kkk="+kkk);
       System.out.println("xaDataSource="+xaDataSource);
//        UserService test = JNDIHelper.getJNDIService("osgi:service/"+UserService.class.getName()+"/(osgi.jndi.service.name=openjpa/userservice)");
//
//        test.showUser();

    }

    @Override
    public void start(BundleContext bundleContext) throws Exception {
               this.bundleContext=bundleContext;
    }

    @Override
    public void stop(BundleContext bundleContext) throws Exception {
        //To change body of implemented methods use File | Settings | File Templates.
    }
}
